#include "stdafx.h"
#include "ylStringUtils.h"

using namespace yoctolog;


std::wstring StringUtils::ToUnicode(const std::string& strInput)
{
	if( strInput.empty() )
	{
		//("StringUtils::ToUnicode : Cannot convert empty string; Aborting.");
		return L"";
	}

	DWORD dwNum = MultiByteToWideChar (CP_UTF8, 0, strInput.c_str(), -1, NULL, 0);
	wchar_t* pBuff = new wchar_t[dwNum];
	if( !pBuff )
	{
		//("StringUtils::ToUnicode : Unable to create wide character buffer; Aborting.");
		delete [] pBuff;
		return L"";
	}

	/*int iCharactersWritten = */MultiByteToWideChar(CP_UTF8,
		0,
		strInput.c_str(),
		-1,
		pBuff,
		dwNum);

	std::wstring strResult = pBuff;
	delete[] pBuff;

	return strResult;
}